home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Reference Guide
/
C-C++ Interactive Reference Guide.iso
/
c_ref
/
csource4
/
263_01
/
manual
< prev
next >
Wrap
Text File
|
1990-02-15
|
75KB
|
2,010 lines
INTRODUCTION
============
This is a summary manual for the "c_wndw" and "c_ndx" libraries. It is
in three parts:
o An alphabetical list of the functions in the libraries.
o A list of the structs and enums defined for the libraries.
o A list of the configuration constants and variables.
This manual and the "c_wndw" and "c_ndx" computer software is the copyright
of Marietta Systems, Inc., 1987, 1988, 1989. Marietta Systems, Inc. is
located in Cobb County, Georgia.
Duplication of the shareware-issued computer software and this manual
for non-commercial purposes is encouraged. Amendment or sale of the
computer software or manual not permitted except as specifically authorized
in writing by an officer of Marietta Systems, Inc.
Marietta Systems does NOT warrant that the computer software will meet your
requirements or that the operation of the computer software will be
uninterrupted and error free. You are solely responsible for the selection
and use of the computer software to achieve your intended results and for
the results actually obtained.
Product specifications and features are subject to change without notice.
dBase III Plus is a trademark of Ashton-Tate.
Marietta Systems "c_wndw" library is a Trademark of Marietta Systems, Inc.
Marietta Systems "c_ndx" library is a Trademark of Marietta Systems, Inc.
Copyright (c) 1987, 1988, 1989 by Marietta Systems.
All rights reserved.
The shareware libraries are issued for the medium memory models in the
MC_WNDW.LIB and MC_NDX.LIB library files.
The header files are the C_WNDW.H and C_NDX.H files.
A) FUNCTION LIST
================
###########################
#include <c_wndw.h>
int accept (byte *field, enum _JUST just, enum ATTRIB atb, int len,
int dec)
int acptbig (byte *field, enum _JUST just, enum ATTRIB atb, int len,
int width)
The functions provide for the formatted and validated input of a
string from the console. The string is displayed at the current
cursor position within the current window while being entered.
fields Either an ASCIIZ string or a compressed date.
just The format of field: left, right, center, as_typed, code,
decimal, db_number, c_number, date
Note: left and as_typed are the only types for acptbig()
atb The display attribute during entry (ex: high etc.).
len 1 - 254 for the size of text strings (format type left, right,
center, as_typed).
1 - 24 for the number of digits before the decimal point of
numeric strings (format type code, decimal, c_number,
db_number).
Ignored for format type date.
dec 0 - 8 for the number of decimal places of format type
decimal, c_number or db_number.
Ignored for all other format types.
width Field display area width for the acptbig() function. This has
a range of 20 to 'len'.
The functions return (-1) for a parameter error, zero if the 'Enter'
key is used, or positive number identifying the valid function key
used. The function key code is also stored in INCHAR.
###########################
#include <c_wndw.h>
int acptchar (char *field, enum _JUST just, enum ATTRIB atb,
unsigned len)
int acptdbl (double *field, enum _JUST just, enum ATTRIB atb,
unsigned len, unsigned dec)
int acptint (int *field, enum _JUST just, enum ATTRIB atb, unsigned len)
int acptlong (long *field, enum _JUST just, enum ATTRIB atb, unsigned len)
#include <c_ndx.h>
int acptmony (mony *field, enum _JUST just, enum ATTRIB atb, unsigned len)
The functions accept entry of numbers at the current cursor position
with justification 'just', using video attribute 'atb'. The operator
interface of these functions are identical to the accept() function.
field Pointer to the field containing the number.
just Format of field: code, decimal, db_number, or c_number.
(code not applicable to acptmony()).
atb The display attribute during entry (ex: high etc.).
len The number of digits to be entered:
char From 1 to 2.
double From 0 to 24 (digits before decimal point).
int From 1 to 4.
long From 1 to 9.
mony From 1 to 7 (digits before decimal point).
dec 0 - 8, the number of digits after the decimal point for a
double type field.
Note: Both 'len' and 'dec' cannot be zero.
The returns are the same as for the accept() function.
###########################
#include <c_ndx.h>
int acptdbf (int fh, unsigned field, enum ATTRIB atb)
The function provides for the entry of a field from a dbase3 or
hashed type file with a dBASE-compatible data dictionary. The
function behaves like the accept() function, except the field details
are taken from the data dictionary. This includes field size and
justification.
fh The file handle of the dbase3 or hashed type file.
field The field number from the data dictionary.
atb The display attribute.
Return values as for the accept() function.
###########################
#include <c_wndw.h>
int acptmask (byte *field, byte *mask, enum ATTRIB atb)
Accepts and formats the entry of a string using a character mask to
format and control the entry.
field The field to be entered.
mask The mask to use in entering the string. This must not be
greater than SCRN_WID characters in size.
atb The screen attribute to use during entry.
The return values are as for the accept() function.
###########################
#include <c_wndw.h>
int acptmenu (byte *field, byte *list, enum ATTRIB atb, unsigned len)
The function accepts entry of a string and validates it against a
list of options. If not present the operator can select an entry
from a menu of these options.
field The string to be entered.
list The list of optional entries in menu() format.
atb The screen attribute to use during entry.
len The length of the field. Range of 1 to 32.
The return values are as for the accept() function, plus (-3) when
inadequate heap space is available.
###########################
#include <c_ndx.h>
mony atom (byte *text)
The function converts a ASCIIZ string of a number with two decimal
places into a mony type field. In keeping with the spirit of atol()
and atoi(), the function does not validate the 'text' parameter string
and ignores the optional decimal point.
text The function expects an ASCIIZ string formatted:
[whitespace][sign][digits][.]dec-digits
Ex: " -345.67", "67", " 345.78", "2345"
The function returns a mony type field with the binary value of the
input string. There is no error checking or error return.
###########################
#include <c_ndx.h>
int cacheoff (int fh)
The function disables "c_wndw" disk caching for file 'fh'. Disk
caching can be re-initiated with the fileinit() function.
fh The file whose caching is to be disabled.
The function returns 0 for success, -1 if the file is not open.
###########################
#include <c_wndw.h>
void clr_keys (void)
The function clears the activated flag of all optional "end of field"
function keys. The only permanently activated keys for the accept()
and its related functions are 'ENTER' and 'F10 - Quit'.
###########################
#include <c_wndw.h>
void clr_scrn (char *title)
The function must be called at the start of the program to initialize
the window and file buffers used by the "c_wndw" software. It also
clears the screen and sets up the base window #0. The 'title' is
displayed centered on the top line.
The function can subsequently be used several times in the program
to clear the screen and change the screen title.
title The screen title of up to 32 characters.
void main () {
clr_scrn ("Main screen title");
display ("hello world", 12, 35, blink);
read_kb();
goodbye (0);
}
###########################
#include <c_wndw.h>
void clr_wndw (void)
The function clears the current window.
###########################
#include <c_ndx.h>
int compress (byte *text)
The function compresses a string by stripping trailing spaces and
replacing any group of TAB_SET number of spaces with a '\t'
character.
text The ASCIIZ string to be compressed.
The function returns the new length of the string (excluding the zero
terminator byte).
###########################
#include <c_wndw.h>
byte* concat (byte *field, int spaces)
The function strips trailing spaces off the string 'field', optionally
adding 1 or 2 depending on the value of 'spaces'.
field The field to be stripped of trailing spaces
spaces The number of spaces to leave at the end of the string
Range (0 - 2).
The function returns a pointer to the new end of the string.
###########################
#include <c_wndw.h>
int datecomp (char *d1, char *d2)
Compares two dates held in "c_wndw" compressed format. The function
handles null dates "00/00/00" as dates before any valid date.
d1 The first compressed date
d2 The second compressed date
The function returns
Zero if d1 == d2
Positive if d1 > d2
Negative if d1 < d2
If the dates are within 80 years, the return value is the number of
days difference.
###########################
#include <c_wndw.h>
long datelong (char *d1)
Converts the compressed date 'd1' to a count of the number of days
since 1/1/80.
d1 The date in compressed "c_wndw" format
The function returns the number of days since 1/1/80. For example:
Jan 2, 1980 yields (1L), and Dec 31, 1979 yields (-1L).
###########################
#include <c_wndw.h>
void datemath (char *d1, int days)
Adds the specified number of days to the compressed date 'd1'. The
'days' variable can be negative for subtraction.
d1 The date to be changed.
days The number of days to add or subtract from the date.
###########################
#include <c_wndw.h>
void dateread (char *d1)
Accesses the system clock to get today's date in compressed "c_wndw"
format.
d1 Today's date is returned in this 3 char date field
###########################
#include <c_wndw.h>
void date_in (char *d1, char *text)
void date_out (char *text, char *d1)
These functions convert dates in and out of "c_wndw" compressed 3
char format. date_in() converts into compressed format and date_out()
converts out of compressed format.
d1 The date in compressed 3 char "c_wndw" format
text The ASCIIZ format date
###########################
#include <c_ndx.h>
void dbfdatein (char *d1, char *dbdate)
void dbfdateout (char *dbdate, char *d1)
These functions convert dates between dBASE format and "c_wndw"
compressed 3 char format. dbfdatein() converts into compressed
format and dbfdateout() converts out of compressed format.
d1 The "c_wndw" compressed 3 char date format.
dbdate The eight char dBASE date format.
###########################
#include <c_ndx.h>
int dbffield (int fh, char *fldname)
The function scans a hashed or dbase3 type file for the field number
corresponding to the 'fldname' parameter.
fh The file handle of the hashed or dbase3 file.
fldname The field name in dBASE format.
If found, the function returns the field number in the range 0 to 253.
Otherwise, it returns (-1).
###########################
#include <c_ndx.h>
int dbffile (int ndx)
The function returns the dbase3 file handle for the index file 'ndx'.
ndx File handle for an index file opened by the ndxcustom(),
ndxrdex(), or ndxopen() functions.
If 'ndx' is a valid index file, the function returns the file handle
of the dbase3 file it indexes. The function returns (-1) if 'ndx' is
not a valid index file.
###########################
#include <c_ndx.h>
double *dbfgetf (int fh, unsigned field, double *fdest)
long *dbfgetl (int fh, unsigned field, long *ldest)
mony *dbfgetm (int fh, unsigned field, mony *mdest)
char *dbfgets (int fh, unsigned field, char *cdest)
The functions get a field from the current record of a dbase3 or
hashed type file and format it correctly.
dbfgetf() Takes a numeric field from the file and returns it as a
double type field.
dbfgetl() Takes the integer part of a numeric field and returns it
as a long type field.
dbfgetm() Takes a numeric field with 2 decimal places and returns
it as a mony type field.
dbfgets() Returns the identified field as an ASCIIZ string, except
dates are returned in 3 char "c_wndw" compressed
date format.
fh The file handle of the hashed or dbase3 type file.
field The number of the field (range of 0 to 253).
cdest A pointer to the area to return the string for the field from
the file. The size is in element dbf_len in the struct
DBF_DEF for the file.
fdest The parameter to return the double value.
ldest The parameter to return the long value.
mdest The parameter to return the mony value.
The function returns NULL for an error, or a pointer to the destin-
ation field if successful.
###########################
#include <c_ndx.h>
int dbflist (int fh, char *list, int max, unsigned mask)
The function produces a list of field names of a dbase3 or hashed
type file. This list of names is suitable to be passed directly to
the menu() function.
fh The file handle of the dbase3 or hashed-type file.
list The buffer area for the field list. This must be at least of
size ((max << 4) + 2).
max The maximum number of field name elements that can be
fitted within the 'list' buffer area.
mask The field type(s) to be selected by the the function:
0X0 For C, D, L, N field types (special case).
0X1 For C (character string) field type.
0X2 For D (date) field type.
0X4 For L (logical) field type.
0X8 For M (memo) field type.
0X10 For N (numeric) field type.
The function returns (-1) for a parameter error or the number of
fields extracted from the data dictionary (range of 0 to 'max').
The field list is returned sorted in alpha-numeric sequence.
###########################
#include <c_ndx.h>
int dbfputf (int fh, unsigned field, double d_src)
int dbfputl (int fh, unsigned field, long l_src)
int dbfputm (int fh, unsigned field, mony m_src)
int dbfputs (int fh, unsigned field, char *c_src)
The functions put a field into the current record of a dbase3 or
hashed type file and format it correctly using the information from
the data dictionary.
dbfputf() Converts a double type field to a N (numeric), D (date),
or M (memo) type field.
dbfputl() Converts a long type field to a N (numeric) or M (memo)
type field.
dbfputm() Converts a mony type field to a N (numeric) type field.
dbfputs() Converts an ASCIIZ string or 3 char "c_wndw" format
compressed date to a suitable form for the type of the
field and loads it into the record.
fh The file handle of the hashed or dbase3 file type.
field The number of the field (range of 0 to 253).
c_src A pointer to the ASCIIZ string or compressed date.
f_src The double value.
l_src The long value.
m_src The mony value.
The functions return (-1) for an error, or zero if successful.
###########################
#include <c_ndx.h>
int dbfread (int fh, enum F_READ mode)
The function reads the file 'fh' and all related files. The parameter
'fh' can be a dbase3 or hashed type file, or an index file. The
relationships to other files are established with the dbfrelate()
function.
This function provides automatic relational multi-file reads and is
key to the use of the relational database facilities in the "c_ndx"
library. Multiple files can be linked at multiple levels with the
dbfrelate() function, and then read with a single dbfread() call.
If a read to a related file fails, the function space fills the
record of that file, and sets its status byte in position 0 to EMPTY.
For example: for related file 'fh4', the following establishes if a
successful read from disk occurred:
/* fh4 is related to fh1, read by ndx1 index file */
ret = dbfread (ndx1, random);
if (ret > 0 && FN[fh4].record[0] != EMPTY) {
/* Process the result of a successful read to fh4 */
......
}
fh The primary file to be read. This can be hashed, dbase3 or
an index file.
mode The read mode. This can be firstrec, lastrec, nextrec,
previous or random.
The function returns:
1 Successful read to the main file.
0 Unsuccessful read to the main file. Top/end of file for a
sequential read, or not found for random.
-1 File/disk error.
-2 Parameter error.
-4 Hashed random read on the main file abandoned after 200
hashed hits.
-5 Corruption in the relationship information.
-7 Disk cache error.
###########################
#include <c_ndx.h>
int dbfrelate (int fh1, int fh2, int ndx, char *fields)
The function establishes a relationship between files 'fh1' and 'fh2'.
These files can be dbase3 or hashed file types.
fh1 The dbase3 or hashed file to be related.
fh2 The dbase3 or hashed file to relate to file 'fh1'.
ndx If 'fh2' is a dbase3 file, 'ndx' is the index file used
in the relationship between 'fh1' and 'fh2'.
If 'fh2' is a hashed file, 'ndx' must be 0.
fields A string naming the fields in the relationship. These fields
must be common to both 'fh1' and 'fh2', and are space
separated.
The function returns 0 for success and negative for error.
The error returns are:
-1 A named field is not present in 'fh1'.
-2 A named field is not present in 'fh2'.
-3 'fh2' is hashed, and a named field is not part of the key.
-4 A named field is not of the same type in both 'fh1' and 'fh2'.
-5 'fh1' and 'fh2' have already been related.
-6 Parameter error.
-7 Inadequate heap memory is available.
-8 Attempt made to open an 8th relationship on file 'fh1'.
/* Program to read through three related files in index sequence
* of primary file.
* One of the related files is accessed through an index
* and one is accessed through hashed random techniques */
void main () {
int ret, one, two, three, ndx1, ndx2;
clr_scrn ("");
/* Open the files and the indexes */
one = fileopen ("DATFILE1.DBF", dbase3, readonly);
ndx1 = ndxopen (one, "DATFILE1.NDX");
two = fileopen ("DATFILE2.DBF", dbase3, readonly);
ndx2 = ndxopen (two, "DATFILE2.NDX");
three = fileopen ("DATAFILE.HSH", hashed, readonly);
/* Setup the relationships */
if (dbfrelate (one, two, ndx2, "SURNAME ZIP_CODE") < 0) goodbye (2);
if (dbfrelate (one, three, 0, "STOCK_ID") < 0) goodbye (3);
/* Read through 'one' with automatic join to 'two' and 'three' */
for (ret = dbfread (ndx1, firstrec) ; ret == 1 ;
ret = dbfread (ndx1, nextrec) {
list_records (one, two, three); /* user written function */
}
err_wndw ("End of file reached", 0, 0); /* press ESC to end program */
goodbye (0);
}
###########################
#include <c_ndx.h>
int dbf_fld (int fh)
The function returns the number of fields in the data dictionary of a
dbase3 or hashed type file.
fh The file handle of the file
The functions returns 0 if the file is not open, does not have a data
dictionary, or is not of type hashed or dbase3. Otherwise it returns
the number of the fields in the data dictionary in the range 1 to 254.
###########################
#include <c_wndw.h>
int dispchar (char field, int rx, int ry, enum ATTRIB atb, enum _JUST
just, unsigned len);
int dispdbl (double field, int rx, int ry, enum ATTRIB atb, enum _JUST
just, unsigned len, unsigned dec);
int dispint (int field, int rx, int ry, enum ATTRIB atb, enum _JUST just,
unsigned len);
int displong (long field, int rx, int ry, enum ATTRIB atb, enum _JUST just,
unsigned len);
#include <c_ndx.h>
int dispmony (mony field, int rx, int ry, enum ATTRIB atb, enum _JUST
just, unsigned len)
The functions display the numeric value of 'field' with format 'just'
at cursor position (rx, ry) using attribute 'atb'. As a special case,
position (0, 0) is interpreted to refer to the current cursor location.
field The field containing the number.
char Range of -99 to 99.
double Virtually any number allowed.
int Range of -9999 to 9999.
long Range of -999999999 to 999999999.
mony Range of -9999999.99 to 9999999.99 .
x The display row within the current window.
y The display starting column location within the current
window.
just Format of field: code, decimal, db_number, or c_number.
(code not applicable to dispmony()).
atb The display attribute (ex: high, reverse, etc.).
len The number of digits to be displayed.
char From 1 to 2.
double From 0 to 24 (digits before decimal point).
int From 1 to 4.
long From 1 to 9.
mony From 1 to 7 (digits before decimal point).
dec 0 - 8, the number of digits after the decimal point for a
double type field.
The functions return (-1) for parameter error, and zero if correct.
###########################
#include <c_ndx.h>
int dispdbf (int fh, unsigned field, int rx, int ry, enum ATTRIB atb)
The function provides for the display to the screen of a field from a
dbase3 or hashed type file with dBASE compatible data dictionary. The
field details are taken from the data dictionary, including field
type, size and justification.
fh The file handle of the file.
field The field number from the data dictionary.
rx The display row within the current window.
ry The display starting column location within the current
window.
atb The display attribute.
The function returns (-1) for parameter error, 0 for success.
###########################
#include <c_wndw.h>
void dispkeys (void)
The function redisplays the bottom line of the screen provided
BOT_LINE is non-zero.
###########################
#include <c_wndw.h>
void display (byte *field, int rx, int ry, enum ATTRIB atb)
The function displays the string ASCIIZ 'field' at cursor position
(rx, ry) within the current window with the color pair attribute 'atb'.
The string can contain any of the IBM graphics characters in addition
to the ASCII character set. As a special case, position (0,0) is
interpreted to refer to the current cursor location.
field The ASCIIZ string to be displayed.
rx The display row within the current window.
ry The display starting column location within the current
window.
atb The display attribute value.
###########################
#include <c_wndw.h>
int dispmask (byte *field, int row, int col, enum ATTRIB atb, byte *mask)
The function display a string at the identified location after
formatting it through the character mask.
field The field to be displayed after formatting.
row The starting row location within the current window.
col The starting column location within the current window.
atb The screen attribute to use for display.
mask The mask to use in formatting the string.
The function returns zero for success, (-1) if the 'mask' did not
contain any formatting characters and (-2) for a parameter error.
###########################
#include <c_wndw.h>
int dispwndw (unsigned wndw, byte *field, unsigned rx, unsigned ry,
enum ATTRIB atb);
The function displays 'field' at cursor position (rx, ry) within
window 'wndw' using attribute 'atb'. 'field' must fit on one line
and be entirely visible. The test must not be hidden or partially
hidden in the window.
wndw The number of the window to display within.
This must be <= W_NUM
field The ASCIIZ string to be displayed.
rx The display row within window 'wndw'.
ry The display starting column location within window 'wndw'.
atb The display attribute value.
The function returns 0 for a successful display, (-1) if the field
string would have been partially or completely hidden, or (-2) for a
parameter error.
###########################
#include <c_ndx.h>
int dispwrap (byte *text, int rx, int ry, enum ATTRIB atb, unsigned height,
unsigned width);
The function displays a scrollable block of text to the screen. The
function supports word-wrap and the '\t', '\n', '\v', and '\f' control
codes. The function ignores the '\r' and '\b' codes. If the text is
too long for the screen area assigned to it, operator controlled
scrolling is supported.
text The text to be displayed. Up to 32 Kbytes spanning up to
254 lines.
rx The starting screen row within the current window.
ry The starting screen column within the current window.
atb The display atribute.
height The number of screen rows available for the display of the
text. This must be at least 7.
width The line width for displaying the text. This must be at least
16.
The display box described by the 'rx', 'ry', 'height' and 'width'
parameters must fit within the current window.
The function returns (-2) for a parameter error, or the value of the
last used function key.
Return values of CRS_UP, CTL_ENT and PGUP indicate the operator
exited from the top of the text display, values of CRS_DN, PGDN and
ENTER indicate the operator exited from the bottom of the text
display. The other possible return values are ESC, HELP and QUIT.
###########################
disp_err() disp_msg() disp_qry()
Obsolete functions entirely replaced in the latest version of the
"c_wndw" library. disp_err() and disp_msg() by the err_wndw()
function, and disp_qry() by the qry_wndw() function.
###########################
#include <c_wndw.h>
int err_wndw (byte *text, int errcode, int ret)
The function creates a window and displays the message in 'text'.
The window is the minimum size needed for the error message. The
window is located near the current cursor position, without
overwriting it.
text A multi-line text string containing the message to be
displayed. Lines can be up to 60 characters wide, or
terminated with the '\n' character. Up to five lines
can be displayed.
errcode If non-zero, this code is displayed in the window.
ret If positive, the message window is only be displayed for that
number of clockticks (18 per second). If zero or
negative, the message window is displayed until the
ESC key is pressed.
The function returns the value of the 'ret' parameter. The function
automatically removes its window when it exits.
###########################
#include <c_wndw.h>
int fileback (char *fname)
The function erases any prior file with the ".BAK" extension, and
then renames the named file to have the ".BAK" extension. The file
is set to read-only mode.
fname The name of the file to be set to backup mode
The return values are as follows:
1 Successful.
0 File cannot be found.
-1 File/disk error.
-2 Parameter error.
-3 Fail because of attempt to backup a ".BAK" file.
-4 Cannot backup an open file.
-5 The old backup file cannot be deleted, or new file renamed.
###########################
#include <c_wndw.h>
int fileclos (int fh)
Closes the file identified with file handle 'fh'. If the file has
indexes opened with the ndxcustom(), ndxopen() or ndxrdex() function,
these are also closed.
fh The file handle number of the file to be closed.
The function returns:
0 Successful, or the file was already closed.
-1 File or disc error
-2 A parameter error.
###########################
#include <c_wndw.h>
int fileinit (int fh, unsigned start, unsigned rec_len, long max_rec)
Sets the record length of the file and the size of the header area at
the start of the file. The function is required for binary type
files after successful fileopen().
fh The file handle number of the file.
start 0 - 65,521 the size of the header area of the file.
rec_len 1 - 32,767 the record length. Must be <= DISCBLCK.
max_rec 0L through LONG_MAX the number of records in the file.
Generally only used for ascii type files.
The function returns:
0 Successful.
-1 The file is not open.
-2 A parameter error.
###########################
#include <c_ndx.h>
int filelist (char *list, char *mask, unsigned max, int type, char *path)
The function extracts a set of file names from a directory. The files
are returned as the ASCIIZ string 'list' in menu() format.
list The returned list of file names.
mask The directory path name and file name mask to be searched which
must contain at least one '*' or '?' metacharacter.
max The maximum number of file names that can be fitted into the
area pointed to by the 'list' parameter. Range 1 to 254.
type The DOS file type attribute.
path A pointer to an area of at least 61 bytes. The function
returns the directory path from the 'mask' parameter.
The function returns (-1) for parameter error, (-2) if the 'mask'
parameter has an invalid path. If successful it returns the number
of files extracted in a range of 0 to 'max'.
###########################
#include <c_ndx.h>
int filemenu (char *name)
The function uses a menu of file names to allow the operator to
select a file name. The parameter to the function is the directory
path and filename mask. The selected file name is returned in the
same parameter.
name The directory path and file name mask. If a file is selected
by the operator, its path and name are returned
through this parameter.
The function returns:
1 A file was selected by the operator.
0 No files match the mask, or the operator pressed the
'F10 - Quit' or 'Esc' key during menu selection.
-1 Parameter error.
-2 Invalid path name.
-10 Insufficient heap memory.
###########################
#include <c_wndw.h>
int fileopen (char *fname, enum F_TYPE type, enum F_MODE mode)
The function opens the file given by 'fname' with file-type 'type' and
under file-mode 'mode'.
fname The name of the file to be opened.
type The type of the file.
mode The access mode of the file.
The function returns zero if the file name cannot be found, or the
file handle value if successful. On error, the function returns:
-1 File/disc error
-2 Parameter error
-4 File already open
###########################
#include <c_wndw.h>
int fileread (int fh, enum F_READ mode, long *rec_nbr)
Reads a record from the file handle 'fh' with read-mode 'mode'. The
function can be used to read a specific record from a file, or to read
through a file sequentially. The file can be read sequentially
forwards or backwards.
fh The file handle of the file
mode The read action mode:
rec_nbr For relative reads, the record number to be read.
The first record in the file is record number 1L.
The function returns
1 A successful read
0 End or top of file
-1 File/disc error
-2 Parameter error
-6 Read-mode not recognized
-7 Cache error
On a successful read, the 'rec_nbr' parameter contains the number
of the next record in the file. For example, after reading the first
record in a file, 'rec_nbr' is set to 2L.
###########################
#include <c_wndw.h>
long filerecno (int fh)
The function returns the number of the current record for a binary,
dbase3 or hashed type file.
fh The file handle of the file.
The function returns 0L for an empty file, (-1L) for a parameter
error or a positive number for the number of the current record.
The first record is 1L.
###########################
#include <c_ndx>
int filesave (int fh)
The function performs cache and file buffer flushing for one or all
open files. The function is used to force file changes to disk and
out of the "c_wndw" cache and the DOS file buffers.
fh If a valid file handle, the function just flushes that file,
otherwise flushes all open files.
The function returns the number of files actually flushed.
###########################
#include <c_wndw.h>
int fileseek (int fh, long loc)
Performs a seek on the file to a specified byte location. The function
is rarely used as the fileread() function performs positioning as
required. If successful the new file location is set into component
location of FN[].
As a special case, a fileseek() with 'loc' of (-1L) positions to the
end of file.
fh The file handle of the file.
loc The target byte location in the file.
The function returns:
0 Successful file movement
-1 File/disc error
-2 Parameter error
###########################
#include <c_wndw.h>
int filewrit (int fh, long *rec_nbr)
The function writes a record from the buffer FN[fh].record to the
file. This is a fixed length record unless the file type is ascii.
For ascii type files the function writes a record through to the first
'\n' or '\0' byte, up to the maximum length of the record (from
FN[fh].rec_len), and terminates each record with "\r\n".
fh The file handle of the file.
rec_nbr The number of the record to be written.
The function returns:
0 On a successful write.
-1 File/disc error
-2 Parameter error
###########################
#include <c_wndw.h>
int fld_len (enum _JUST just, unsigned len, unsigned dec)
This returns the required size of a string to hold a field with
justification 'just' and size 'len' with decimal places 'dec'. For
numeric fields, the 'len' parameter refers to the digits before the
decimal point.
just The format of the field:
len 1 - 254 for the size of text strings (format type left, right,
center, as_typed).
1 - 24 for the number of digits before the decimal point of
numeric strings (format type code, decimal, c_number,
db_number).
Ignored for format type date.
dec 0 - 8 for the number of decimal places of format type decimal,
c_number or db_number.
Ignored for all other format types.
The function returns a value of the size of the string necessary to
hold the field. This is in the range 0 to 254. This value does not
include the zero byte, and is compatible with the strlen() function.
###########################
#include <c_wndw.h>
int flt_wndw (unsigned h, unsigned w, byte *title)
This function creates a floating window of 'h' rows and 'w' columns
next to the current cursor location.
h The number of rows in the window. Range 1 to (SCRN_LEN -
TOP_LINE).
w The number of columns in the window. Range 1 to SCRN_WID.
title The window title.
Returns as as for the mk_wndw() function.
###########################
#include <c_ndx.h>
byte *ftoascii (byte *text, double field, unsigned len, unsigned dec)
The function converts a double to an ASCIIZ string in c_number format,
with leading sign and a properly located decimal point. The number of
decimal places corresponds to the value of the 'dec' parameter. The
function uses ecvt() to perform fractional rounding. If the value of
the double field is too big, the 'text' string is filled with '*'.
text A pointer to an area at least of size (len + dec + 3).
field The double type field to be converted.
len 0 - 24 digits before the decimal point.
dec 0 - 8 digits after the decimal point.
Note: both 'len' and 'dec' cannot be zero.
The function returns a pointer to 'text'.
###########################
#include <c_ndx.h>
mony ftom (double dsrc)
The function converts a double type field into a mony type field. The
value is rounded nearest.
dsrc The double type field to be converted.
The function returns LONG_MAX if the 'dsrc' field is too big to fit in
a mony type field, otherwise it returns the rounded converted value.
###########################
#include <c_wndw.h>
void goodbye (short errcode)
The function must be used to end the program. It closes the files and
resets the configuration changes made by the clr_scrn() function. The
function does not return but calls the exit() function with 'errcode'
to end the program. An 'errcode' of zero is a normal exit, and non-zero
is an error exit.
err_code The code to be passed to the exit() function. Codes of 200
through 254 are reserved for the "c_wndw" software.
void main() {
int fh;
clr_scrn (" File processing program ");
fh = fileopen ("MAINFILE.DBF", dbase3, readonly);
if (fh <= 0) goodbye (1); /* end program on error */
process_file (fh); /* user written function */
goodbye (0); /* normal end to program */
}
###########################
#include <c_wndw.h>
int grabchar (void)
The function waits for entry of a keystroke from the keyboard, then returns
the converted entry character. All key stroke entries, including function
keys, are converted into a single value. The key entered is not echoed
to the screen.
The function returns the value of the keystroke entered. This value
is also set into INCHAR.
###########################
#include <c_ndx.h>
int hashmake (char* fname, unsigned fields, unsigned rec_len, long
max_rec, unsigned key_off, unsigned key_len)
Creates an empty hashed type file of name 'fname', record length
'rec_len', and with 'max_rec' pre-allocated records. The location
of the hash key within the record starts at position 'key_off' with
length 'key_len'. The file is in update mode after successful creation.
fields The number of fields in the data dictionary.
Range of 1 to 254.
rec_len The length of the record including the status byte.
Range of 2 to 32,767. Must be <= DISCBLCK.
max_rec The number of records to create in the file. The actual
record count is rounded to the nearest prime number above
the number requested. Range of 2L to 999,999L.
key_off The start location of the record key.
Range of 1 to ('rec_len' - 'key_len').
key_len The length of the key. Range of 1 to 254.
The returns are as for the fileopen() function.
###########################
#include <c_ndx.h>
long hashread (int fh, byte *key, int access)
The function performs a hashed read to a hashed type file using the
field pointed to by 'key'. The key for the file can be a string or a
binary code (such as a double).
fh The file handle of the file.
key A pointer to the key to be used.
access (0) to read a record from the file.
(1) to find the number of an available record.
If successful, the function returns the record number. Otherwise:
-1L Bad key (key not found with 'access' == 0, or matching key
found with 'access' == 1)
-2L Parameter error.
-4L The read abandoned after 200 attempts. This indicates the
file has very few EMPTY records and needs re-organizing.
###########################
#include <c_wndw.h>
void helpmenu (int item)
The function provides the default help screen for the menu() and
top_menu() functions. The functions pass a parameter identifying
the currently highlighted menu item.
###########################
#include <c_wndw.h>
int helpscrn (byte *field)
The function provides the default help screen for the accept() and
related functions. The parameter is the current entry string contents.
The function always returns (-1).
###########################
#include <c_wndw.h>
void idleloop (int ticks)
The function delays for the number of clock ticks given in the parameter
'ticks'. There are approximately 18.2 ticks per second, 1092 per minute.
ticks The number of clock ticks to delay.
###########################
#include <c_ndx.h>
int iscache (int fh)
The function returns whether the "c_wndw" disk access caching facilities
are active on file 'fh'. The file must be of type hashed, dbase3 or binary.
fh The file handle.
The function returns 0 if access to the file 'fh' does not use "c_wndw"
disk caching, or 'fh' is not a valid or open file. Otherwise the
function returns the disk cache size in records.
###########################
#include <c_wndw.h>
int isendch (byte *field, int c, enum ATTRIB atb)
The function is primarily used by the accept() and related functions and
returns (1) if the parameter 'c' is a valid "end of field" function key
code as determined by set_keys(), unset_keys() and clr_keys(). A zero or
negative value means it is not currently an "end of field" key.
###########################
#include <c_ndx.h>
int isuniqndx (int ndx)
The function returns 1 if the index file uses unique keys, or 0 if the
index allows duplicate keys or is not a valid index file.
ndx A valid index file opened with ndxcustom(), ndxopen(), or ndxrdex().
###########################
#include <c_wndw.h>
byte *justify (enum _JUST just, byte *dest, byte *src, unsigned len,
unsigned dec)
The function copies and justifies string 'src' into string 'dest', using
the length parameters 'len' and 'dec'. The function is used to automatically
expand and truncate strings, and to format and extract numeric fields.
just The desired format of the destination string:
dest Pointer to the destination string.
src Pointer to the source string.
len 1 - 254 for the size of text strings (format type left right,
center, as_typed)
1 - 24 for the number of digits before the decimal point of
numeric strings (format type code, decimal, c_number,
db_number).
Ignored for format type date.
dec 0 - 8 for the number of decimal places of format type decimal,
c_number or db_number.
Ignored for all other format types.
The function returns NULL for an error, or a pointer to the destination
string if successful.
###########################
#include <c_wndw.h>
int lastline (byte *field, unsigned col, enum ATTRIB atb)
The function provides the means to write to the bottom line of the
screen. This allows the programmer to customize the display on this
protected line of the screen instead of using the dispkeys() function.
field The ASCIIZ string to be displayed.
col The column location to start displaying the string.
Range of 1 through SCRN_WID.
atb The display attribute.
The function returns (1) if the 'field' was successfully displayed, zero
if it was displayed but truncated, and negative for error. The function
returns (-1) if BOT_LINE is non-zero, and (-2) for a parameter error.
###########################
#include <c_ndx.h>
int ln_ex (byte *dest, byte *src, unsigned len)
The function extracts a line of text from a string, expanding any '\t'
characters into groups of spaces.
dest Pointer to the destination string.
src Pointer to the source string.
len Required length of the destination string. Range of 1 to 254.
The function returns the number of characters read from 'src', or
returns zero if 'len' is greater than 254.
###########################
#include <c_wndw.h>
int maskfield (byte *dest, byte *src, byte *mask)
This function applies a character mask to a field. The 'mask' string
can contain punctuation and masking characters. The masking characters
are A, C, N, S, X. This is not case sensitive.
dest The pointer to the destination field.
src The pointer to the source field.
mask The pointer to the masking field.
If successful the function will return the count of masking characters
in the 'mask' field. The function returns (-2) for a parameter error.
/* format a 10 digit field as a USA style phone number */
maskfield (out, phonenumber, "(NNN) NNN-NNNN");
###########################
#include <c_wndw.h>
int menu (char *menutext, int size, int start, int up)
Displays the menu from the string 'menutext' within the current window
starting from the current cursor position. Each menu item must be
terminated with a '&' or '|' character.
menutext A string consisting of the items of the menu.
size The maximum displayed size of a menu item. This must be non-zero
and fit on the line in the current window. For multiple items
per line, at least one space is left between each item.
start The initially selected menu item.
up The maximum number of items per line.
up <= (WINDOW[W_NUM].W - _CURSOR.Y + 1) / (size + 1)
The function returns a positive number corresponding to the item selected
where the first item is (1). The other return values are:
0 The 'F10 - Quit' or 'ESC' key was used.
-1 No memory available on the heap.
-2 Parameter error. Note: the most common parameter error
is for 'size' and 'up' to specify items that cannot fit on
the line in the current window.
/* A menu of a vertical column of items, the fourth item not allowed */
item = menu("Small&Compact&Medium&Huge|Large&", 7, 1, 1);
###########################
#include <c_wndw.h>
int mk_wndw (int ax1, int ay1, int ax2, int ay2, byte *title)
Creates a window from the coordinates of its top left hand corner
(ax1, ay1), and bottom right hand corner (ax2, ay2). The string
'text'is displayed on the top border of the window. All reading and
writing to the screen occurs within the bounds of the current window
using the display() and accept() and related functions.
The body of the window must fit within the main screen display area,
however the borders of the window can be outside and need not be
visible. The maximum window size that displays the borders is:
mk_wndw (TOP_LINE + 1, 1, SCRN_LEN - 1, SCRN_WID, "title")
ax1 The row number of the top left hand corner of the window.
This must be >= TOP_LINE.
ay1 The column of the top left hand corner of the window.
This must be >= 0.
ax2 The row number of the bottom right hand corner.
This must be <= SCRN_LEN and at least 2 rows below 'ax1'.
ay2 The column of the bottom right hand corner of the window.
This must be <= (SCRN_WID + 1) and at least 2 columns to the
right of 'ay1'.
title The title for the top border of the window.
If successful, the function returns a positive number of the window number
just created. This number is also set into W_NUM. The error returns are:
-1 Too many windows (compared to _WINDW).
-2 No memory available.
-3 W_NUM contains an invalid number.
-4 Invalid coordinates.
/* Create a window with an internal area of 9 by 69 */
ret = mk_wndw(5, 5, 15, 75, "Test window");
###########################
#include <c_ndx.h>
mony monydisc (mony amount, mony discount)
mony monydiv (mony amount1, mony amount2)
mony monymarkup (mony amount, mony markup)
mony monymult (mony amount1, mony amount2)
mony monypercent (mony amount, mony divisor)
mony monyratio (mony amount, double ratio)
The functions perform common arithmetic functions with mony type fields
as operands. The functions handle overflow situations, rounding and the
maintenance of the two implied decimal places.
monydisc() Take a discount of a mony field.
monydiv() Divide one mony field into another.
monymarkup() Markup one mony field by another.
monymult() Multiply two mony fields.
monypercent() The percentage one mony field is of another.
monyratio() Apply a ratio to a mony field.
The functions return LONG_MAX if the result of the calculation is outside
the range (-9,999,999.99) to (9,999,999.99). If successful, they return
the rounded value of the result of the calculation.
###########################
#include <c_ndx.h>
byte *mtoascii (byte *dest, mony msrc)
double mtof (mony msrc)
The functions convert mony type fields to double type and ASCIIZ string
fields.
msrc The mony type field to be converted.
dest Pointer to the destination string for mtoascii().
This must be at least 13 bytes in size.
###########################
#include <c_ndx.h>
int ndxappend (int ndx)
The function appends a record to an indexed dbase3 file opened in update
or append mode. The parameter to the function is the file handle of an
index on the file. This index file must have been previously opened with
the ndxcustom(), ndxopen() or ndxrdex() function.
ndx The file handle of an index file opened on a dbase3 type file
by the ndxcustom(), ndxrdex(), or ndxopen() function.
The function returns the following values:
0 Successful write.
-1 Attempt to write a record with a duplicate key where an
index file requires unique keys.
-2 A write error on the disk.
-3 Record status byte not set to IN_USE.
-6 Parameter error.
###########################
#include <c_ndx.h>
int ndxcustom (int fh, char *xname, int (*makekey)(), int type)
The function opens an index on a dbase3 type file, using a custom index
function. The index key entries are calculated with the 'makekey'
function passed as a parameter. The custom index function is not supplied
with the "c_wndw" and "c_ndx" software.
The custom index function must have the following parameters:
int makekey (int fh, int tag, void *ptr, char *key);
Where 'makekey()' is the name of the function, 'fh' is the dbase3 file
handle, 'tag' is an initialization flag passed to the function by the
"c_ndx" software and 'key' is the pointer to the key returned by the
function. The parameter 'ptr' must not be used by the custom index function.
The custom index function is initialized by being called with 'tag' equal
zero. Subsequent calls to the custom index function are made with 'tag'
set non-zero. The function is expected to return the key for the current
record in file 'fh' as the 'key' parameter. The function must return 0
for success or negative for error.
fh The file handle of the dbase3 file to be indexed.
xname The name of the index file.
makekey() The name of the custom index function.
type This identifies the type of the key and should be one of the
following values:
0 Key is an unterminated string.
1 Key is of type double.
3 Key is a dBASE-type date key field held as a double.
If successful, the function returns a positive number of the file handle
of the index file. Otherwise the function returns:
0 The named file cannot be found.
-1 The index file is entirely empty or corrupted.
-2 Parameter error (ex: fh is not open, or is not a dbase3 type
file, or DISCBLCK < 512).
-4 The named index file is already open.
-5 Insufficient heap memory available.
-8 If this would be the 8th index on the file.
###########################
#include <c_ndx.h>
int ndxdelete (int ndx)
The function flags the current record from the dbase3 file as deleted, and
writes it back out to disk. The file is identified through the index
file 'ndx'.
ndx The file handle of the index file.
The function returns zero if successful, (-1) for disk/file error or
(-2) for a parameter error.
###########################
#include <c_ndx.h>
int ndxfield (int ndx, unsigned fnbr)
The function returns the data field number of the 'fnbr' index field.
ndx The file handle of an index file opened on a dbase3 file
type with the ndxopen() or ndxrdex() functions. Custom
indexes are not supported.
fnbr The index field sequence number (from a base of 0).
The function returns (-1) if 'ndx' is not a valid index file, or the index
field number does not exist. If successful, it returns the data dictionary
field number (range 0 - 253).
###########################
#include <c_ndx.h>
int ndxopen (int fh, char *xname)
The function opens an index file on a dbase3 file. The details on the
index are obtained from the information in the index file. This information
includes whether the index is numeric, or has unique keys.
The parsing system and index calculation logic supports a subset of the
dBASE index calculation logic covering the vast majority of indexes in
use in existing dBASE compatible B-tree index files.
fh The file handle of the dbase3 file to be indexed.
xname The name of the index file.
If successful the function returns a positive number of the file handle
of the index file. Otherwise the function returns:
0 The named file cannot be found.
-1 The index file is entirely empty or corrupted.
-2 Parameter error (ex: 'fh' is not open, or is not a dbase3 type
file, or DISCBLCK < 512).
-4 The named index file is already open.
-5 Insufficient heap memory available.
-7 The index expression cannot be parsed.
-8 If this would be the 8th index on the file.
###########################
#include <c_ndx.h>
int ndxrdex (int fh, char *xname, char *exprn, int (*makekey)(), int type)
The function creates or recreates an index on a dbase3 file. It supports
both dBASE compatible and custom indexes. The function is the only way
to create a custom index on a file.
fh The file handle of the dbase3 type file to be indexed.
xname The name of the index file. If the file exists, it is replaced.
If it does not exist it is created. If the 'exprn' and
'makekey' parameters are both NULL, 'xname' must be a valid,
existing index file to be re-indexed by the ndxrdex() function.
exprn If not equal to NULL, this points to valid dBASE index expression
of up to 220 bytes in length. If the 'makekey' parameter is
not equal NULL 'exprn' is for documentation only, but otherwise
is evaluated for the key calculation logic as described above.
makekey If not equal to NULL, this is the custom key calculation
function, more fully described under the ndxcustom() function.
type This flag is used to identify characteristics of the key.
On successful completion, the function returns the file handle of the index
file. The error returns are:
-1 Parameter error.
-5 Insufficient heap memory available.
-7 (custom key only) The 'makekey' function returned an error.
-8 Attempt to open the 8th index on a file.
###########################
#include <c_ndx.h>
int ndxread (int ndx, enum F_READ mode)
The function performs a random or sequential read on a dbase3 file via the
index file 'ndx'. The parameter 'mode' identifies the type of the read.
Performing a random read involves moving the fields in the key into the
record. The ndxread() function then builds the key and retrieves the
matching record from the file. If a matching record cannot be found,
the function retrieves the record with the next higher key.
ndx The file handle of the index file.
mode The read action mode:
firstrec The first record in index sequence.
nextrec The next record in index sequence.
previous The previous record in index sequence.
lastrec The last record in index sequence.
random Retrieve a record randomly using a key search
through the indexes.
All values of 'mode' return 1 for a valid, successful read. random
returns 0 if an exact key match was not found, and retrieves the record
with the next higher key. The other values of 'mode' return 0 at the
top/end of the file.
The error returns of the function are:
-1 File/disc error.
-2 Parameter error.
-7 Disk cache error.
###########################
#include <c_ndx.h>
int ndxwrite (int ndx)
The function writes a record to an indexed dbase3 file opened in update or
append mode. The parameter to the function is the file handle of an index
on the file.
If the dbase3 file was opened in append mode, the effect of using ndxwrite()
is identical to using ndxappend(). If the file was opened in update mode,
the function overwrites the current record on disk.
ndx The file handle of an index file opened on a dbase3 type file.
The function returns the following values:
0 Successful write.
-1 Attempt to write a record with a duplicate key to an index
file requiring unique indexes.
-2 A write error on the disk.
-6 Parameter error.
###########################
#include <c_wndw.h>
long primenbr (long source)
Returns the first prime number equal to or higher than the number
provided. The function is accurate for 'source' values between 8L
and 29,999,999. 'source' values under 8L return (11L).
source The number to be converted to a prime.
The function returns the prime number if successful, or:
-1L 'source' is negative or greater than 29,999,999.
-4L No heap memory available.
###########################
#include <c_wndw.h>
void prn_scrn (void)
The function prints a copy of the screen onto the main printer. This
works with any printer as the IBM graphics characters used by the
mk_wndw() function are translated to ASCII equivalents, and any
other graphics characters are replaced with the '#' character.
The function is automatically activated by pressing the 'Alt+P' key.
###########################
#include <c_wndw.h>
int qry_wndw (byte *text)
The function creates a window, displays the message in 'text', and prompts
for a yes/no response.
text A multi-line text string containing the query to be displayed.
Lines can be up to 60 characters wide, or terminated with
the '\n' character. Up to five lines can be displayed.
The function returns (1) for a BOOL_YES entry and (0) for a BOOL_NO entry.
The function automatically removes its window when it exits.
if (qry_wndw(" Do you want to finish entry? ")) return;
###########################
#include <c_wndw.h>
void read_kb (void)
Reads and ignores a keyboard entry. If the 'Alt+X' keys are pressed the
function prompts for a controlled termination.
###########################
#include <c_wndw.h>
int rm_wndw (void)
Removes the current window and redisplays the part of the screen covered
by it. All screen activity now takes place in the previous window.
The main window, window #0 cannot be removed.
If successful, the function returns a positive number of the window
removed. If unsuccessful, it returns:
-1 Attempt to remove window #0.
-3 System error.
/* Remove all windows */
while ( rm_wndw () > 0);
###########################
#include <c_wndw.h>
void scrnsave (int posn)
A function used by accept(), read_kb(), err_wndw() and qry_wndw() functions.
If the functions have to wait longer than SAVEWAIT ticks for a keyboard
entry, all file buffers are flushed.
while (!isascii(c)) {scrnsave(0); c = grabchar();}
###########################
#include <c_wndw.h>
void scrn_map (byte *field, int ax, int ay)
The function writes the 'field' string onto the screen starting at the
(ax, ay) location using the current color code (set by set_clr()). The
function uses absolute screen not relative window coordinates and can be
used to write anywhere on the screen without regard to windows.
###########################
#include <c_wndw.h>
void scroll (int incr, int head)
The function scrolls the window up or down according to the 'incr'
parameter, leaving a header of 'head' lines unscrolled.
incr The number lines the window scrolls. Negative for scrolling
down, positive for up.
head The size of an unscrolled header area at the top of the
window.
If the parameters are invalid, the function does not scroll.
/* To scroll up by 2 lines all but the first 3 lines of a window */
scroll (2, 3);
###########################
#include <c_wndw.h>
void set_clr (int clr_nbr, enum ATTRIB atb)
The function is used to change the color code used by the scrn_map()
function. The color code is selected from COLOR[], by applying the effect
of the attribute 'atb'. The function also works to select the display
attribute on monochrome screens.
clr_nbr The array index element selected from COLOR[], or a special case
entry. This can be 95, 98 or 99, or >= 0 and < _COLORS.
atb The screen attribute color variation.
###########################
#include <c_wndw.h>
void set_crsr (int rx, int ry)
The function moves the cursor within the current window to the location
given by (rx, ry). The function wraps around from an invalid location
to one that fits in the window.
rx The row location within the current window.
ry The column location within the current window.
###########################
#include <c_wndw.h>
void set_keys (unsigned count, unsigned param1, ...)
The function determines which function keys are recognized by accept()
and related functions as "end of field" function keys.
It has a variable function list which allows a large number of keys to
be set. The key codes are defined in the c_wndw.h header file. For
example: CRS_UP for cursor up key.
count A count of the number of keys to be set.
param1... The parameter list of keys to be set.
set_keys (5, CRS_UP, CRS_DN, PGUP, PGDN, HELP);
###########################
#include <c_wndw.h>
int set_wndw (unsigned wnbr, enum _JUST just, enum ATTRIB atb,
unsigned style)
The function sets the window characteristics of border styles and title
formats for windows. The set_wndw() function must be called before the
mk_wndw() function in order to properly set up the format.
wnbr The number of the window to set. This window need not be
active, and if active this has no effect until the window
is removed and re-activated. The range is 1 to _WINDW.
just The format of the title. This must be left, center, or right.
atb The screen attribute for the title.
style The style of the window border as follows:
0 Double line box (the default).
1 Single line box.
2 Light hatch box.
3 Heavy hatch box.
The function returns (-1) on error, zero on success.
###########################
#include <c_wndw.h>
void shortbeep (int tone)
The function produces beep of duration ERR_BEEP clock ticks, with a
minimum beep duration of two clock ticks. There are 18.2 clock ticks
to the second. The tone of the beep is based on the 'tone' parameter.
###########################
#include <c_wndw.h>
int sys_wndw (byte *text, int errcode, int ret)
The function behaves exactly as the err_wndw() function except the window
is only displayed if ERRORMSG is non-zero. This is used extensively in the
"c_wndw" and "c_ndx" functions to allow the error displays to be suppressed
by setting ERRORMSG to zero after your programs have acheived a stable status.
###########################
#include <c_wndw.h>
int top_menu (char *menutext, int size, int start)
The function displays the menu across the top line of the screen. The
items have a maximum size of 27 bytes and the full menu must fit on one
line. The returns are as for the menu() function. This menu is independent
of the window system.
k = top_menu ("Amend&Create&Delete&Extract&Report&", 9, k);
###########################
#include <c_wndw.h>
void top_spot (int val)
Refreshes the status values on the top line of the screen. These status
values are the screen title, available memory, date, and available capacity
on the default disk drive.
If TOP_LINE is zero, the function does not output to the screen.
val 0 refreshes the whole status line.
1 refreshes the available memory percent display.
2 refreshes the status of "INSERT" at bottom right of screen
by calling the dispkeys() function.
3 refreshes available disk percent display.
4 refreshes the date display.
###########################
#include <c_wndw.h>
void unset_keys (unsigned count, unsigned param1, ...)
The function deactivates function keys from being used as "end of field"
keys by the accept() and related functions.
It has a variable function list which allows a large number of keys
to be unset. The key codes are defined in the c_wndw.h header file.
For example: CRS_UP for cursor up key.
count A count of the number of keys to be unset.
param1... The parameter list of keys to be unset.
unset_keys (3, CRS_UP, CRS_DN, HELP);
###########################
#include <c_wndw.h>
int validate (byte *line, enum _JUST just, unsigned len, unsigned dec)
The function evaluates the value of 'line' to ensure it is valid. If
'line' is of type date, the month and day are validated. If 'line' is of
type c_number, db_number or decimal, it is checked to see if it has too
many digits before the decimal point.
line The string to be evaluated.
just The format of the string to be evaluated.
len The number of digits before the decimal point.
dec The number of decimal digits.
The function returns zero if 'line' is invalid and (1) if valid.
###########################
#include <c_wndw.h>
int v_bool (int c)
Tests the character 'c' against comparison characters stored in BOOL_NO
and BOOL_YES. It is not case sensitive.
The function returns (2) if 'c' is BOOL_YES, (1) if 'c' is BOOL_NO, and
zero if neither BOOL_YES nor BOOL_NO.
###########################
#include <c_wndw.h>
void warble (int tone)
Turns on the computer's speaker to the tone provided. As a special case,
a tone of zero shuts off the speaker.
B) enum AND struct DEFINITIONS
==============================
enum ATTRIB {low, high, reverse, blink, blank, alt_low, alt_high,
alt_reverse};
Defines the screen attribute code to select which of the 6 color pairs
are to be used, plus supports blink and blank fields. This is used
with the accept(), display(), set_clr() and related functions.
enum COLOR_OF {Mblack, Mblue, Mgreen, Mcyan, Mred, Mmagenta, Myellow,
Mwhite};
Defines the 8 base colors used by the software, which extend to 16
with the high/low intensity options.
enum fld_type {alphanum, graphic, flag, boolean, calendar, numeric, value,
real, chrono}:
Defined for future use.
enum F_MODE {append, readonly, recreate, update};
Defines the file access mode for the fileopen() function. All access
modes are available with all file types except append with hashed,
and update with ascii.
enum F_READ {firstrec, previous, nextrec, lastrec, random, relative};
Defines the file read mode for the dbfread(), fileread() and ndxread()
functions.
enum F_TYPE {ascii, binary, dbase3, hashed, marietta};
Defines the file type for the fileopen() function. ascii type files
have variable length records terminated with "\r\n", whereas binary,
dbase3 and hashed files have fixed length records which may contain
binary information.
enum _JUST {left, right, as_typed, center, code, decimal, db_number,
c_number, date, _time};
Defines field format (justification) codes used by the accept() (and
related functions), fld_len(), and justify() functions.
struct CLR_TYPE {enum COLOR_OF FORE, BACK; int ALT_CLR}
COLOR[], TOP_CLR, ER_COLOR;
Defines the primary color pair, and the number of the alternate
color pair for the windows, and the top and bottom lines.
struct CURSR {byte X,Y;} _CURSOR;
Contains the current cursor location within current window.
struct DBF_DEF {byte dbf_name[11]; int dbf_type, dbf_len, dbf_dec,
dbf_set, dbf_dig; enum _JUST just; unsigned posn; ... };
Defines the field format of the dBASE style data dictionary created
when a hashed or dbase3 file is opened with the fileopen() function.
struct F_DEF {long prime, r_count; int key_len, offset, start, ismemo;
unsigned rec_len; enum F_TYPE ftype; byte *record; char
fname[13], fvol, fpath[61]; void *fnext; ...} *FN;
Defines the buffers and control variables used by the "c_wndw" and
"c_ndx" file access software.
struct WINDW {int X, Y, H, W, .......} *WINDOW;
Defines the buffers and sizes used by the "c_wndw" windowing
software. The number of usable columns in the current window is
(WINDOW[W_NUM].W - 1) and the number of usable rows is
(WINDOW[W_NUM].H - 1).
typedef unsigned char byte;
Used in the "c_wndw" software to contain values in the range (0) to
(254). The value (255) by convention is viewed as an error or a null
value.
typedef long mony;
A mony type field is of storage class long, but includes two implied
decimal places (ex: cents in a dollar field). It is the programmer's
responsibility, on this type of field, to keep track of these decimal
places. The mony field type can contain a signed binary number in
the range (-9,999,999.99) to (9,999,999.99). The value LONG_MAX
by convention is viewed as an error value.
C) CONFIGURATION CONSTANTS AND VARIABLES
========================================
ACC_DISP This enum ATTRIB type field determines the attribute used
by the accept() function to re-display the entered field after
entry.
A_TRACK Used by the accept() function. If negative it is ignored,
but otherwise becomes the starting cursor position within the
display string. At the end of the accept() or related
function, this is the string location where the function key
was pressed.
BANNER_MSG[] The contents of the information window that appears when
the clr_scrn() function is first called, or when the operator
presses the Alt+V key combination.
BOOL_NO Identifies the uppercase boolean no/false code.
BOOL_YES Identifies the uppercase boolean yes/true code.
BOT_LINE This controls the display of the active function keys on the
bottom line of the screen.
CLR_TONE The length of time, in clock ticks, for the display of the
initial information window during the clr_scrn() function.
The default is 25, about 1.5 seconds.
COMMA Identifies the thousands separator character.
_COLORS The maximum number of color pairs.
D_FORMAT Provides the format of the date. The default is 'U'.
'U' = mm/dd/yy; 'E' = dd/mm/yy; 'I' = yy/mm/dd.
DISCBLCK The maximum size of any record accessed by fileread(),
filewrit() or related functions. The default is 4100, the
minimum is 512, and the maximum 65,000.
D_PUNCT Identifies the punctuation character for dates.
D_20XX Identifies the split between the 20th and 21st centuries
for 2 digit year fields.
ERR_BEEP This determines the length of the beep by the shortbeep()
function in clock ticks.
ERRORMSG This is used to suppress the error messages displayed by the
"c_wndw" and "c_ndx" software.
FLD_FULL Used by the accept() function. A non-zero value automatically
ends field entry when it is full. A zero value requires the
ENTER key (or an activated function key) to end the field.
GOODBYEMSG This is used by the goodbye() function. If non-zero the
function issues success or failure messages at the end of the
program. If zero, these messages are suppressed.
KEY_DISPLAY[] This array of seven short strings contains the key names
of function keys F3 through F9.
MAXFILES Maximum number of files open at one time, including the five
standard C streams. The default value of 9 actually allows
for 4 disk files. The maximum is set by your operating system.
20 is typical, but it can be as high as 99.
MAX_WIND The maximum heap space to be used by the windowing functions.
MEM_WARN A warning is issued by the top_spot() function when
available heap space falls below this value. The default is
1024, with a range of 0 to 9999.
MENULINE This determines if an information line for menus is displayed
on the bottom line of the screen while the menu() and
top_menu() functions are active.
PERIOD Identifies the decimal point character which must be different
from COMMA.
SAVEWAIT The scrnsave() function waits this time (in clockticks) before
flushing the file buffers. Setting to zero supresses this
facility.
SCRN_LEN The number of lines on the screen. This is normally the
default of 25. It allows utilization of 43 and 50 line per
screen systems.
SCRN_WID The number of columns on the screen. This should remain 80.
TOP_LINE The number of lines dedicated for status line and the
top_menu() function at the top of the screen.
_WINDW The maximum allowed number of windows.